package com.surelution.projects.congress

import org.codehaus.groovy.grails.commons.GrailsApplication;

class DynPictureController {

    def member = {

		if (request.method == 'HEAD') {
			render( text : "", contentType : "image/jpeg"    );
	    } else {
			response.contentType = "image/jpeg";
			
			def id = params.id
			def file = grailsAttributes.applicationContext.getResource("pics/" + id + ".jpg").file
			if(!file.exists()) {//picture doesn't exist
				file = grailsAttributes.applicationContext.getResource("images/no.gif").file
			}
			byte[] bs = file.readBytes()
			response.outputStream << bs
		}
	}
}
